From: Jan Beulich Date: Tue, 3 Dec 2013 08:57:41 +0000 (+0100) Subject: common/vsprintf: fix return value when formatting symbolic addresses X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5822^2~9 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=fd62e281dfe6183cd140cf2cf2bca1a10b574aa7;p=xen.git common/vsprintf: fix return value when formatting symbolic addresses When the buffer to be formatted to is too small, the function return value is expected to be the number of characters that would be printed (particularly important if that value is then used for allocating a buffer). Hence incrementing the active pointer must always be independent of actually storing a character. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Acked-by: Keir Fraser --- diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c index 43dc392916..1a6198e4d3 100644 --- a/xen/common/vsprintf.c +++ b/xen/common/vsprintf.c @@ -294,7 +294,8 @@ static char *pointer(char *str, char *end, const char **fmt_ptr, /* Print '+/' */ str = number(str, end, sym_offset, 16, -1, -1, SPECIAL|SIGN|PLUS); if ( str <= end ) - *str++ = '/'; + *str = '/'; + ++str; str = number(str, end, sym_size, 16, -1, -1, SPECIAL); }